package Java.Array;

public class Demo02 {
    public static void main(String[] args) {
        int[] arrays = new int[15];
        for (int i = 0; i < arrays.length; i++) {
            arrays[i] = i;
        }
//        for(int array:arrays){
//            System.out.println(array);
//        }
//        printArray(arrays);
////        reverseArray(arrays);
//        for (int array:reverseArray(arrays)) {
//            System.out.print(array+" ");
//        }
        printArray(reverseArray(arrays));
    }

//    方法
public static void printArray(int[] arrays) {
    for (int i = 0; i < arrays.length; i++) {
        System.out.print(arrays[i] + " ");
    }
}

    public static int[] reverseArray(int[] arrays) {
        int[] reversedArray = new int[arrays.length];
        for (int i = 0,j=reversedArray.length-1; i < arrays.length; i++,j--) {
            reversedArray[j] = arrays[i];
        }
        return reversedArray;
    }

}
